window.onload = function () {
    console.log("testJs");
}
function weekBtn() {
    let ob = document.getElementById("week");
    console.log(ob.value)
    var dateStr = ob.value;
    var year = parseInt(dateStr.split("-W")[0]);
    var weekNum = parseInt(dateStr.split("-W")[1]);

// 获取第一天的日期
    var startDate = new Date(year, 0, (weekNum - 1) * 7 + 1);

// 获取最后一天的日期
    var endDate = new Date(startDate.getTime());
    endDate.setDate(endDate.getDate() + 6);

// 格式化日期
    var startDateStr = startDate.toISOString().slice(0, 10);
    var endDateStr = endDate.toISOString().slice(0, 10);

// 输出结果
    var formattedDate = startDateStr + " - " + endDateStr;
    console.log(formattedDate);
    // 设置文本内容为年月日时分秒
   }


function datetimeBtn() {
    let obj = document.getElementById("datetime").value;
    let text = document.getElementById("text");
    let data1 = new Date(obj);
    console.log(data1)
    // 分别打印年月日时分秒
    console.log(data1.getFullYear());
    console.log(data1.getMonth() + 1);
    console.log(data1.getDate());
    console.log(data1.getHours());
    console.log(data1.getMinutes());
    console.log(data1.getSeconds());
    // 设置文本内容为年月日时分秒
    text.innerText = data1.getFullYear() + "-" + (data1.getMonth() + 1) + "-" + data1.getDate() + " " + data1.getHours() + ":" + data1.getMinutes() + ":" + data1.getSeconds();
}